package com.qf.Dao.Impl;



import com.qf.Dao.CategoryDao;
import com.qf.Entity.Category;
import com.qf.Util.DruidUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/*2021/10/9*/public class CategoryDaoImpl implements CategoryDao {
    QueryRunner queryRunner=new QueryRunner();
    @Override
    public List<Category> selectAllCategory() {
        try {
            return queryRunner.query(DruidUtil.getConnection(), "select c_name cName from category;", new BeanListHandler<>(Category.class) );
        } catch (SQLException e) {
            throw new RuntimeException("查询药品分类信息时出现异常："+e.getMessage());
        }
    }
}
